//
// Created by hunan on 25-3-23.
//
#include "test_socket_server_of_tls.h"
#include <tls_socket_server_connection.h>
#include <loop_module/loop.h>
#include <gtest/gtest.h>

TEST(TlsTest, Print)
{
    printf("hello.\n");
}

TEST(TlsSocketServer, Listen)
{
    Loop loop;
    auto server = std::make_shared<TlsSocketServer>(&loop);
    SocketServer::Option option = {};
    option.m_crt_file = "/home/hunan/open/open_net/cmake-build-debug/public_module/socket_module/test/server.crt";
    option.m_private_key_file = "/home/hunan/open/open_net/cmake-build-debug/public_module/socket_module/test/server.key";
    option.m_listen_port = 10024;
    server->SetOnConnection([](const std::shared_ptr<SocketServerConnection> & connection) {

        printf("new connection.\n");
    });
    server->SetOnMessage([](const std::shared_ptr<SocketServerConnection> & connection, int ret, SocketServer::Message & message) {

        printf("recv size : %d.\n", message.m_data_length);
    });
    if (server->BindAddress(option) >= 0)
    {
        server->Listen();
        loop.Run();
    }
}